# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=wmi-client
pkgver=1.3.13
pkgrel=7
pkgdesc='Linux WMI client.'
arch=('any')
url='https://bitbucket.org/instarch/wmi-client/'
license=("GPL2")
depends=('gnutls' 'python2')
groups=('blackarch' 'blackarch-networking')
source=("http://dev.zenoss.org/svn/branches/zenoss-3.2.x/inst/externallibs/wmi-$pkgver.tar.bz2"
        'gnutls.patch'
        'python3.patch')
sha512sums=('126875c34b3741c443d05663dafcd594ede22727'
          '98a11b6db867aa8a2b93509ff32007979b7cc1f7'
          'a5bd31a5be524e8121c4f7ef14675d54cd3a81f6')

prepare() {
  cd "wmi-$pkgver"

  patch -Np0 -i ../gnutls.patch
  patch -Np0 -i ../python3.patch

  find "$srcdir" -type f -exec grep -sl '^#!/usr/bin/python$' {} \; |
  xargs sed -i 's|/usr/bin/python$|&2|'

  # Fix evil makefile.
  sed -i '/^pywmi-installed:/s/pywmi-build//' GNUmakefile
}

build() {
  cd "wmi-$pkgver"

  make build
}

package() {
  cd "wmi-$pkgver"

  export ZENHOME="$pkgdir/usr"

  make install
}

